<script setup>
	import { onLaunch } from "@dcloudio/uni-app"
	import { useUserStore, useWebConfigStore } from "@/stores";
	import { $http, useStorage,$tool } from '@/utils'
	import system from "@/utils/system";

	onLaunch((options) => {
		const appid = options.query?.appid || system.appid();
		if (appid) {
			useStorage().set('APPID', appid)
		}
		const pid = options.query?.user_id;
		if (pid) {
			useStorage().set('PID', pid);
		}
		useWebConfigStore().initWebConfig()
		$http.get('Config/getConfig').then(res => {
			useWebConfigStore().setWebConfig(res.data)
			uni.$emit('initConfig')
		}).catch(err => {
			uni.showModal({
				title: '温馨提示',
				content: '系统配置项错误'
			})
		})
		
		
		const scene = options.query?.scene;
		if (scene) {
			const sceneArr = decodeURIComponent(scene).split('&');
			const sceneObj = {};
			sceneArr.forEach(item => {
				const arr = item.split('=');
				sceneObj[arr[0]] = arr[1];
			})
			if (sceneObj.id) {
				useStorage().set('PID', sceneObj.id);
			}
		}
		const { setUserInfo } = useUserStore()
		let token = options.query?.token;
		if (token) {
			$tool.replaceUrlParam('token', '')
			setUserInfo({ token: token }).then(() => {}).catch(() => {});
		}
	})
 
</script>

<style lang="scss">
	/*每个页面公共css */
	@import "static/y.scss";
	@import "static/iconfont.css";

	page {
		letter-spacing: 4rpx;
		background-color: #181818;
	}


	.btn-normal {
		display: block;
		margin: 0;
		padding: 0;
		line-height: normal;
		background: none;
		border-radius: 0;
		box-shadow: none;
		border: none;
		font-size: unset;
		text-align: unset;
		overflow: visible;
		color: inherit;
	}

	.btn-normal:after {
		border: none;
	}

	.btn-normal.button-hover {
		color: inherit;
	}

	button:after {
		content: none;
		border: none;
	}

	image {
		vertical-align: bottom;
	}

	view {
		box-sizing: border-box;
	}
</style>